exports.remove=function(req,res,next){
    var id = req.params.id;
    Cate.find().then(data=>{
      var a = removeTree(data,id);
      Cate.remove({ _id: { $in: a } }).then(() => {
        res.json({ message: '删除多个记录成功', status: 200 });
      });
    })
  
  }
  
  function removeTree(data,id){
    var result = [],
    temp;
    var data = JSON.parse(JSON.stringify(data));
    for(var i in data){
      //console.log(data[i].path);
      var a = data[i].path.split(',');
      for(var j of a){
        if(j==id){
          result.push(data[i]._id);
        }
      }
    }
    result.push(id);
    return result;
  }